package com.ellricky.baselib.adapter

import android.widget.RadioButton
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.adapter.SmartViewHolder
import com.andr.common.util.EmptyUtil
import com.andr.common.util.StrUtil
import com.ellricky.baselib.R
import com.ellricky.baselib.entity.new.MyClueData

class ClueSelectAdapter : BaseRecyclerAdapter<MyClueData>(R.layout.base_adapter_clue_select) {

    override fun onBindViewHolder(vh: SmartViewHolder, p1: MyClueData, p2: Int) {
        var title = StrUtil.filterEmpty(p1.clue_name)
        val sexName = StrUtil.filterEmpty(p1.clue_sex)
        val age = StrUtil.filterEmpty(p1.clue_age)
        if (!EmptyUtil.isEmpty(sexName)) {
            title += " $sexName"
        }
        if (!EmptyUtil.isEmpty(age)) {
            title += " $age"
        }
        vh.text(R.id.tvTitle, title)
        vh.text(R.id.tvClue, p1.from_name)
        vh.text(R.id.tvPhone, p1.clue_tel)
        vh.text(R.id.tvDate, "录入时间:${p1.clue_input_time}")
        val rb = vh.itemView.findViewById<RadioButton>(R.id.rb)
        rb.isChecked = p1.isSelect
    }
}